<template>
  <div class="son-page-container" :style="{ backgroundImage: `url(${website_bg_url})` }">
    <el-container class="main-container">
      <el-header height="10vh" class="header-container">
        <MyHeader />
      </el-header>
      <el-main>
        <el-row :gutter="20">
          <el-col :span="24">
            <div class="area-container right-area">
              <iframe
                  :src="deepseekUrl"
                  class="webview-frame"
                  frameborder="0"
                  allowfullscreen
              ></iframe>
            </div>
          </el-col>
        </el-row>
      </el-main>
    </el-container>
  </div>
</template>

<script setup lang="ts">
import {onMounted, ref} from 'vue'
import axiosUtil from '../../axios-util/axios-util'
import MyHeader from '../common/MyHeader.vue';
import LocalStorageUtil from "../../utils/LocalStorageUtil.ts";

const deepseekUrl = ref(import.meta.env.VITE_APP_SERVER+'storeplugin/ai_ds&menu_url=ai_ds&storeid='+
    LocalStorageUtil.get("id")+'&token='+LocalStorageUtil.get("token"))

// 网站背景图
const website_bg_url = ref('')

onMounted(() => {
  initWebsiteBgUrl()
})

//读取配置，获取网站背景图
const initWebsiteBgUrl = async () => {
  const response = await axiosUtil.post('api/pc/site/get_agent_config', {})
  if (response.data.code === 0 && response.data.data) {
    website_bg_url.value = import.meta.env.VITE_APP_SERVER + response.data.data.website_bg || ''
  }
}
</script>

<style scoped>
.son-page-container {
  position: relative;
  width: 100%;
  min-height: 100vh;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.main-container {
  height: 100vh;
  width: 100%;
  backdrop-filter: blur(5px);
}

.header-container {
  padding: 0;
  width: 100%;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.el-main {
  padding: 20px;
  height: 90vh;
  overflow-x: hidden;
}

.el-row {
  height: 100%;
  margin: 0 !important;
  /* 新增：允许flex子项收缩 */
  min-height: 0;
}

.el-col {
  height: 100%;
  /* 新增：允许flex子项收缩 */
  min-height: 0;
}

.area-container {
  height: 100%;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  padding: 15px;
}

.area-container:hover {
  background: rgba(255, 255, 255, 0.15);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
}

.right-area {
  min-height: 70vh;
}

.webview-frame {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 8px;
}
</style>
